package sc.test.spring.prop;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import sc.common.test.TestUtil;

@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class PropertiesTest4 {

    @Value("${tester}")
    public String tester;

    @Value("#{springcoolProps.defaultValue}")
    public String defaultValue;

    @Value("#{springcoolProps['defaultValue']}")
    public String defaultValue2;

    @Value("#{springcoolProps.overrideTester}")
    public String overrideTester;

    /** 不能用#{springcoolProps.a.b.c.d} */
    @Value("#{springcoolProps['a.b.c.d']}")
    public String abcd;

    @Value("#{springcoolProps2['defaultValue']}")
    public String defaultValue3;

    @Test
    public void t1() {
        TestUtil.sp("PlaceHolder:tester         = " + tester);
        TestUtil.sp("Properties :defaultValue   = " + defaultValue);
        TestUtil.sp("Properties :defaultValue2  = " + defaultValue2);
        TestUtil.sp("Properties :overrideTester = " + overrideTester);
        TestUtil.sp("Properties :a.b.c.d        = " + abcd);
        TestUtil.sp("Properties :defaultValue3  = " + defaultValue3);
    }
}
